home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / EXAMP1.SQL < prev    next >
Encoding:
Text File  |  1995-05-18  |  1.2 KB  |  43 lines

  1. rem 
  2. rem $Header: examp1.sql 7020100.1 94/09/28 16:39:56 cli Generic<base> $ 
  3. rem 
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      examp1.sql - <one-line expansion of the name>
  7. Rem    DESCRIPTION
  8. Rem      <short description of component this file declares/defines>
  9. Rem    RETURNS
  10. Rem 
  11. Rem    NOTES
  12. Rem      <other useful comments, qualifications, etc.>
  13. Rem    MODIFIED   (MM/DD/YY)
  14. Rem     rvasired   05/12/92 -  Creation 
  15. /*
  16. ** This block processes an order for tennis rackets.  It decrements
  17. ** the quantity of rackets on hand only if there is at least one
  18. ** racket left in stock.
  19. **
  20. ** Copyright (c) 1989,1992 by Oracle Corporation
  21. */
  22.  
  23. DECLARE
  24.     qty_on_hand  NUMBER(5);
  25. BEGIN
  26.     SELECT quantity INTO qty_on_hand FROM inventory
  27.         WHERE product = 'TENNIS RACKET'
  28.         FOR UPDATE OF quantity;
  29.  
  30.     IF qty_on_hand > 0 THEN  -- check quantity
  31.         UPDATE inventory SET quantity = quantity - 1
  32.             WHERE product = 'TENNIS RACKET';
  33.         INSERT INTO purchase_record
  34.             VALUES ('Tennis racket purchased', SYSDATE);
  35.     ELSE
  36.         INSERT INTO purchase_record
  37.             VALUES ('Out of tennis rackets', SYSDATE);
  38.     END IF;
  39.  
  40.     COMMIT;
  41. END;
  42. /
  43.